package com.pro.common.api.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.pro.common.api.exception.BusinessBreakException;
import com.pro.common.api.exception.BusinessException;
import com.pro.common.api.exception.BusinessNoTranslateException;

import java.io.Serializable;

public interface IResponseInt<T> extends IResponse<T, Integer> {
    // http异常 直接抛出异常 如果外层允许中断全部任务 则会全部中断 避免无效请求.
    // http正常时,可能接口内容还会额外的有业务错误码
    default void failThrow() {
        if (!isSuccess()) {
            Integer code = getCode();
            if (401 == code) {
                throwUnAuthorization();
            } else {
                throw new BusinessNoTranslateException(500, getMsg());
            }
        }
    }

}
